﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_right : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["admin"] == null)
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "parent.location.href='Login.aspx'", true);
            else
                Label1.Text = Session["admin"].ToString();
        
        }

    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        try
        {
            string pwd = Md5.getMd5(TextBox1.Text);
            string uid=Session["admin"].ToString();
            string sql = "update administrator set password='" + pwd + "' where uid='" + uid + "'";
            DbAccess db = new DbAccess();
            if (db.ExecuteSql(sql))
            {
                TextBox1.Text = "";
                TextBox2.Text = "";
                btnOk.Enabled = false;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('密码修改成功')", true);

            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('密码修改失败')", true);

            }
        }
        catch
        { 
        
        }

    }
}
